package com.cloudxingkong.dianyinke.NewTeacher.Ui;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.cloudxingkong.dianyinke.NewTeacher.Adapter.MTVPAdapter;
import com.cloudxingkong.dianyinke.NewTeacher.Fragment.WeiJieKuanFragment;
import com.cloudxingkong.dianyinke.NewTeacher.Fragment.WeiShangkeFragment;
import com.cloudxingkong.dianyinke.NewTeacher.Fragment.YiFuKuangFragment;
import com.cloudxingkong.dianyinke.R;

import java.util.ArrayList;
import java.util.List;

public class MyStudent extends AppCompatActivity {
    private List<Fragment> listFragment;
    private List<String> listTitle;
    private TabLayout tablayout;
    private ViewPager viewpager;
    private WeiShangkeFragment noHaveClass;
    private YiFuKuangFragment payed;
    private WeiJieKuanFragment noPayed;
    private MTVPAdapter mtvpAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_student);
        init();
    }

    private void init() {
        tablayout = (TabLayout) findViewById(R.id.mt_tablayout);
        viewpager = (ViewPager) findViewById(R.id.mt_viewpager);
        listFragment=new ArrayList<>();
        listTitle=new ArrayList<>();
        noHaveClass = new WeiShangkeFragment();
        payed = new YiFuKuangFragment();
        noPayed = new WeiJieKuanFragment();
        listFragment.add(noHaveClass);
        listFragment.add(noPayed);
        listFragment.add(payed);
        listTitle.add("未上课");
        listTitle.add("未结款");
        listTitle.add("已结款");
        tablayout.setTabMode(TabLayout.MODE_FIXED);
        tablayout.addTab(tablayout.newTab().setText(listTitle.get(0)));
        tablayout.addTab(tablayout.newTab().setText(listTitle.get(1)));
        tablayout.addTab(tablayout.newTab().setText(listTitle.get(2)));

        mtvpAdapter = new MTVPAdapter(getSupportFragmentManager(),listFragment,listTitle);
        viewpager.setAdapter(mtvpAdapter);
        tablayout.setupWithViewPager(viewpager);
    }

    public void back(View view) {
        switch (view.getId()) {
            case R.id.mt_back:
                finish();
                break;
        }
    }

}
